package com.corpgovernment.common.enums;

import java.util.Arrays;
import java.util.Objects;

public enum GenderEnum {

    M("M", "男"),

    F("F", "女");

    private String code;
    private String desc;

    GenderEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static GenderEnum getByCode(String code) {
        return Arrays.stream(GenderEnum.values()).filter(e -> Objects.equals(code, e.code)).findFirst().orElse(null);
    }

    public static GenderEnum getByName(String name) {
        return Arrays.stream(GenderEnum.values()).filter(e -> Objects.equals(name, e.desc)).findFirst().orElse(null);
    }
}
